<template>
  <view class="scan-user" v-if="showPage">
    <view class="header">
      <view class="user-card">
        <view class="user-base">
          <view>
            <image :src="data.imageUrl" class="user-avatar"></image>
            <view class="user-name">{{data.realName || data.nickName}}</view>
            <div class="refresh-bind" v-if="isShowBind" @click="showPopup=true,userList=[],keyWord=''">
              <image src="./../../static/refresh.png"></image>
              重新关联
            </div>
          </view>
          <view>
            <view class="user-total">锦欣总消费</view>
            <view class="user-money">￥{{data.money>0? data.money :0}}</view>
          </view>
        </view>
        <!-- <view class="user-other">
          <view class="user-sex">
            <view>性别</view>
            <view v-if="data.sex>0">{{data.sex===1?'男':'女' }}</view>
            <view>未知</view>
          </view>
          <view class="user-birth" v-if="data.birthday">
            <view>生日</view>
            <view>{{data.birthday}}</view>
          </view>
        </view> -->
        <view class="user-qy" @click="handleGoInterest">权益查询<image src="./../../static/arrow-right.png"></image>
        </view>
      </view>
    </view>
    <view class="search-header">
      <view class="search-title">会员商品订单</view>
      <u-search placeholder="搜索商品" v-model="searchData.productName" :show-action="false" class="search-input" @search="handleSearch"></u-search>
      <view class="search-tabs">
        <view v-for="(item,index) of tab" :key="index" @click="handleActive(item,index)">
          {{item.label}}
          <image src="./../../static/icon_state_off.png" v-if="!item.active"></image>
          <image src="./../../static/icon_state_on.png" v-else></image>
        </view>
      </view>

      <!-- 订单状态 -->
      <view class="search-list" v-show="showTagFilter">
        <scroll-view class="search-container" scroll-y="true" scroll-with-animation="true">
          <view v-for="(item,index) of statusOptions" :key="index" @click="handleActiveTag(item,index)">
            {{item.label}}
            <image src="./../../static/success.png" v-if="item.active"></image>
          </view>
        </scroll-view>
      </view>
      <!-- 使用机构 -->
      <view class="search-list" v-show="showOrgFilter">
        <scroll-view scroll-y="true" scroll-with-animation="true" class="search-container">
          <view v-for="(item,index) of orgList" :key="index" @click="handleActiveOrg(item,index)">
            {{item.label}}
            <image src="./../../static/success.png" v-if="item.active"></image>
          </view>
        </scroll-view>
      </view>
      <!-- 时间 -->
      <view class="search-time" v-show="showTimeFilter">
        <view class="date-container">
          <view class="date-comp">
            <picker-view v-if="visible" :indicator-style="indicatorStyle" :mask-style="maskStyle" :value="value" @change="handleChangeTime">
              <picker-view-column>
                <view class="item" v-for="(item,index) in years" :key="index">{{item}}年</view>
              </picker-view-column>
              <picker-view-column>
                <view class="item" v-for="(item,index) in months" :key="index">{{item}}月</view>
              </picker-view-column>
              <picker-view-column>
                <view class="item" v-for="(item,index) in days" :key="index">{{item}}日</view>
              </picker-view-column>
            </picker-view>
          </view>
          <view class="date-opt">
            <view @click="handleCancelTime">取消</view>
            <view @click="handleConfirmlTime">确定</view>
          </view>
        </view>
      </view>
    </view>

    <view class="list">
      <!-- 筛选的条件 -->
      <view class="filter-tag" v-if="filterTags.length>0">
        <view v-for="(item,index) of filterTags" :key="index">
          {{item.label}}
          <image src="./../../static/close.png" @click="handleDelFilterTag(item,index)"></image>
        </view>
      </view>

      <scroll-view scroll-y="true" :class="['user-list']" scroll-with-animation="true" v-if="list.length>0" @scrolltolower="loadMore">
        <view class="list-item" v-for="(item,index) of list" :key="index">
          <view class="item-status">
            <view>
              <image src="./../../static/icon_hospital.png"></image>
              {{item.orderSourceOrgName || ''}}
            </view>
            <view class="status-text">{{renderStatus(item.status)}}</view>
          </view>
          <view class="item-detail">
            <image :src="item.carouselImageUrl" class="detail-img"></image>
            <view class="detail-info">
              <view>
                <span>{{item.productName}}</span>
                <span>￥{{$commafy(item.totalAmount/100)}}</span>
              </view>
              <view>
                <span v-if="item.startDate && item.endDate">有效期：{{item.startDate}}至{{item.endDate}}</span>
                <span v-if="!item.startDate && !item.endDate">有效期：长期有效</span>
                <span>x{{item.num}}</span>
              </view>
            </view>
          </view>
          <view class="item-bottom">
            <view>
              下单时间：{{item.createTime}}
            </view>
            <view>实付款：<span>￥{{$commafy(item.payAmount/100)}}</span></view>
          </view>
          <view class="item-bottom-opt" v-if="item.status===2 || item.status===6">
            <view>
              已使用{{item.alreadyUseCount}}/{{item.useCount}}次
            </view>
            <view class="opt-container">
              <view class="opt-btn" @click="handleRefund(item)">退款</view>
              <view class="opt-btn" @click="handleShowModal(1,item)" v-if="item.status===2">核销此产品</view>
            </view>
          </view>
        </view>
        <u-loadmore :status="loadStatus" class="loadmore-class" :load-text="loadText" />
      </scroll-view>
      <view class="empty-data" v-if="list.length<=0">
        <image src="./../../static/empty_state.png"></image>
        <view>暂无订单</view>
      </view>
    </view>

    <!-- 关联用户信息 -->
    <u-popup :show="showPopup" closeable @close="handleClosePopup" round="16" class="relink-popup">
      <view class="relink-body">
        <view class="title">重新关联</view>
        <view class="search">
          <u-search placeholder="请输入用户名手机号或姓名" v-model="keyWord" class="search-input" @clear="handleClearUser" @search="handleSearchUser" @custom="handleSearchUser" :show-action="true" actionText="搜索"></u-search>
        </view>
        <view class="no-data" v-if="userList.length<=0">
          <image src="./../../static/empty-nouser.png"></image>
          <span>该用户未关联，请输入用户手机号或姓名进行关联</span>
        </view>
        <scroll-view scroll-y="true" class="list" v-else>
          <view class="list-item" v-for="(item,index) of userList" :key="index">
            <view class="base-info">
              <view>
                <image :src="item.imageUrl"></image>
                <span>{{item.nickName}}</span>
              </view>
              <view class="btn" @click="handleLink(item,index)" v-if="!item.qxUserId">重新关联</view>
              <view class="unbtn" v-else>已关联</view>
            </view>
            <view class="member-name"><span>会员姓名</span><span>{{item.realName}}</span></view>
            <view class="member-mobile"><span>手机号</span><span>{{item.phoneNum}}</span></view>
          </view>
        </scroll-view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import datetimePicker from './../../components/datetime-picker/datetime-picker.vue'
export default {
  components: {
    datetimePicker
  },
  data () {
    const date = new Date()
    const years = []
    const year = date.getFullYear()
    const months = []
    const month = date.getMonth() + 1
    const days = []
    const day = date.getDate()
    for (let i = 1990; i <= date.getFullYear(); i++) {
      years.push(i)
    }
    for (let i = 1; i <= 12; i++) {
      months.push(i)
    }
    for (let i = 1; i <= 31; i++) {
      days.push(i)
    }
    return {
      showPage: false,
      userList: [],
      keyWord: '',
      statusOptions: [
        { label: '全部', value: '', active: false },
        { label: '待支付', value: 0, active: false },
        { label: '支付中', value: 1, active: false },
        { label: '已支付', value: 2, active: false },
        { label: '已完成', value: 3, active: false },
        { label: '已退款', value: 4, active: false },
        { label: '已取消', value: 5, active: false },
        { label: '已过期', value: 6, active: false },
      ],
      filterTags: [],
      list: [],
      orgList: [],
      tab: [
        { label: '下单日期', active: false },
        { label: '使用机构', active: false },
        { label: '订单状态', active: false },
      ],
      data: {},
      loadStatus: 'loadmore',
      loadText: {
        loadmore: '下拉加载更多',
        loading: '努力加载中',
        nomore: '没有更多啦~'
      },
      showTagFilter: false,
      showOrgFilter: false,
      showTimeFilter: false,
      searchData: {
        current: 1,
        size: 15,
        total: 0,
        productName: ''
      },
      memberId: '',
      orgId: '',
      title: 'picker-view',
      years,
      year,
      months,
      month,
      days,
      day,
      value: [9999, month - 1, day - 1],
      /**
       * 解决动态设置indicator-style不生效的问题
       */
      visible: true,
      // indicatorStyle: `height: ${Math.round(uni.getSystemInfoSync().screenWidth/(750/100))}px;`
      indicatorStyle: `height: 50px;`,
      maskStyle: "",
      ckTime: false,
      isShowBind: false,
      showPopup: false,
    }
  },
  onLoad (option) {
    this.initData(option)
  },
  mounted () {
    document.querySelector('body').onclick = (e) => {
      let prevClass = e.target._prevClass
      //  点击时间
      if (prevClass === 'search-time') {
        this.handleCloseTime()
      }
      // 
      if (prevClass === 'search-list') {
        // 使用机构
        if (this.showOrgFilter) {
          this.handleCloseOrgFilter()
        }
        // 订单状态
        if (this.showTagFilter) {
          this.hanldeCloseStatusFilter()
        }
      }
    }
  },
  methods: {
    handleClearUser () {
      this.keyWord = ''
      this.userList = ''
    },
    // 初始化数据
    initData (option) {
      if (option.qywxUserInfo) {
        this.$setStorage("qywxUserInfo", option.qywxUserInfo)
      }
      if (option.code) {
        this.$setStorage("code", option.code)
      }
      if (option.state) {
        let state = option.state
        let stateJSON = state.replace('#wechat_redirect', '')
        if (stateJSON) {
          let state = JSON.parse(stateJSON)
          if (state.orgId) {
            this.$setStorage("orgId", state.orgId) //1
          }
          if (state.memberId) {
            this.$setStorage("memberId", state.memberId) //19
          }
        }
      }
      // 绑定用户入口
      if (option.route) {
        this.isShowBind = true
        this.getUserInfo()
        this.getOrgList()
        this.handleSearch()
        this.showPage = true
      } else {
        this.getValidateUserInfo()
      }
    },
    handleClosePopup () {
      this.showPopup = false
    },
    // 退款/核销弹窗
    handleShowModal (type, item) {
      console.log(item)
      uni.showModal({
        title: '',
        content: type === 2 ? '确认要退款吗?' : '确认要核销此次产品吗?',
        success: (res) => {
          if (res.confirm) {
            // 核销
            if (type === 1) {
              this.verification(item)
            }
          }
        }
      });
    },
    // 核销
    async verification (item) {
      try {
        this.$showLoading()
        let params = {
          productType: 1,
          verificationUserId: this.userInfo.verificationUserId,
          verificationUserPhone: this.userInfo.phone,
          verificationUserOrgId: this.$getStorageSync('orgId'),
          orderId: item.id,
          verificationUserName: this.userInfo.verificationUserName
        }
        const res = await this.$Api.mxp_api('api-shop-member/shop/member/order/verification/verification', 'POST', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          this.handleSearch()
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    },
    // 绑定
    handleLink (item) {
      this.showPopup = false
      uni.showModal({
        content: '确认关联此用户信息吗？',
        success: (res) => {
          if (res.confirm) {
            this.bind(item)
          }
        }
      });
    },
    // 绑定
    async bind (item) {
      try {
        this.$showLoading()
        let params = {
          orgId: this.$getStorageSync('orgId'),
          id: item.id,
          qxUserId: this.$getStorageSync('qxUserId')// 外部联系人id
        }
        const res = await this.$Api.mxp_api('crm-server/jinxinMember/updateMemberCardById', 'POST', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          this.list = res.datas || []
          this.$showToast(res.resp_msg)
          setTimeout(() => {
            this.$setStorage("memberId", item.id)
            this.initData({
              route: "userList"
            })
          }, 1000);
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    },
    // 查询绑定的用户
    async handleSearchUser () {
      try {
        if (!this.keyWord) {
          this.$showToast('请输入用户名手机号或姓名')
          return false;
        }
        this.$showLoading()
        let params = {
          orgId: this.$getStorageSync('orgId'),
          phoneNum: this.keyWord,
        }
        const res = await this.$Api.mxp_api('crm-server/jinxinMember/selectMemberCardByPhoneOrRealName', 'GET', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          this.userList = res.datas || []
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    },
    // 退款
    async handleRefund (item) {
      uni.showModal({
        title: '',
        content: '确认要退款吗?',
        success: (res) => {
          if (res.confirm) {
            this.refund(item)
          }
        }
      });
    },
    // 退款接口
    async refund (item) {
      try {
        this.$showLoading()
        let params = {
          outTradeNo: item.orderCode, // 0权益  1产品 
          outRefundNo: item.orderCode,
          amount: {
            refund: item.payAmount,
            total: item.payAmount
          }
        }
        const res = await this.$Api.mxp_api(`api-shop-member/shop/member/payInfo/refund/0/${this.$getStorageSync('orgId')}`, 'POST', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          this.$showToast(res.resp_msg)
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    },
    // 时间切换
    handleChangeTime (e) {
      const val = e.detail.value
      this.year = this.years[val[0]]
      this.month = this.months[val[1]]
      this.day = this.days[val[2]]
    },
    // 取消时间
    handleCancelTime () {
      this.ckTime = false
      this.year = ''
      this.month = ''
      this.day = ''
      this.filterTags.map((item, index) => {
        if (item.type === 1) {
          this.filterTags.splice(index, 1)
        }
      })
      this.handleCloseTime()
    },
    // 关闭时间弹窗
    handleCloseTime () {
      this.tab.map(tabItem => {
        if (tabItem.label === '下单日期') {
          tabItem.active = false
        }
      })
      this.showTimeFilter = false
    },
    // 时间确定
    handleConfirmlTime () {
      this.ckTime = true
      this.setFilterTag()
      this.tab.map(tabItem => {
        if (tabItem.label === '下单日期') {
          tabItem.active = false
        }
      })
      this.showTimeFilter = false
    },
    // 渲染订单状态
    renderStatus (statusValue) {
      let obj = this.statusOptions.find(item => item.value === statusValue)
      return obj.label
    },
    // 查询
    handleSearch () {
      this.list = []
      this.searchData.current = 1
      this.getList()
    },
    // 选中tab
    handleActive (item, index) {
      this.tab.map(tabItem => {
        if (tabItem.label !== item.label) {
          tabItem.active = false
        }
      })
      item.active = !item.active
      if (item.label === '下单日期') {
        this.showTimeFilter = item.active
        this.showOrgFilter = false
        this.showTagFilter = false
      }
      if (item.label === '使用机构') {
        this.showTimeFilter = false
        this.showOrgFilter = item.active
        this.showTagFilter = false
      }
      if (item.label === '订单状态') {
        this.showTimeFilter = false
        this.showOrgFilter = false
        this.showTagFilter = item.active
      }
    },
    // 选中订单状态
    handleActiveTag (item, index) {
      this.statusOptions.map(statusItem => {
        statusItem.active = false
      })
      item.active = true
      this.hanldeCloseStatusFilter()
      this.setFilterTag()
    },
    // 关闭订单状态弹窗
    hanldeCloseStatusFilter () {
      this.showTagFilter = false
      this.tab.map(tabItem => {
        if (tabItem.label === '订单状态') {
          tabItem.active = false
        }
      })
    },
    // 选中使用机构
    handleActiveOrg (item, index) {
      this.orgList.map(orgItem => {
        orgItem.active = false
      })
      item.active = true
      this.handleCloseOrgFilter()
      this.setFilterTag()
    },
    // 关闭使用该机构弹窗
    handleCloseOrgFilter () {
      this.showOrgFilter = false
      this.tab.map(tabItem => {
        if (tabItem.label === '使用机构') {
          tabItem.active = false
        }
      })
    },
    // 设置tag
    setFilterTag () {
      let tmpList = []
      if (this.year && this.ckTime) {
        tmpList.push({
          label: `${this.year}-${this.month}-${this.day}`,
          type: 1
        })
      }

      this.orgList.map(item => {
        if (item.active) {
          tmpList.push({ label: item.label, value: item.value, type: 2 })
        }
      })
      this.statusOptions.map(item => {
        if (item.active) {
          tmpList.push({ label: item.label, value: item.value, type: 3 })
        }
      })
      this.filterTags = tmpList
      this.handleSearch()
    },
    // 删除筛选tag
    handleDelFilterTag (item, index) {
      if (item.type === 3) {
        this.statusOptions.map(statusItem => {
          if (statusItem.label === item.label) {
            statusItem.active = false
          }
        })
      }
      if (item.type === 2) {
        this.orgList.map(orgItem => {
          if (orgItem.label === item.label) {
            orgItem.active = false
          }
        })
      }
      if (item.type === 1) {
        this.ckTime = false
      }
      this.filterTags.splice(index, 1)
      this.handleSearch()
    },
    // 列表查询
    async getList () {
      try {
        this.$showLoading()
        let params = {
          current: this.searchData.current,
          size: this.searchData.size,
          memberId: this.$getStorageSync('memberId'),
          productName: this.searchData.productName
        }
        this.filterTags.map(item => {
          if (item.type === 2) {
            params.orderSourceOrgId = item.value
          }
          if (item.type === 3) {
            params.status = item.value
          }
          if (item.type === 1) {
            this.year = this.years[val[0]]
            this.month = this.months[val[1]]
            this.day = this.days[val[2]]
            params.startDate = `${this.years}-${this.month}-${this.day} 00:00:00`
            params.endDate = `${this.years}-${this.month}-${this.day} 23:59:59`
          }
        })
        const res = await this.$Api.mxp_api('api-shop-member/shop/member/order/pageList', 'GET', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          let tmpObj = res.datas || {}
          let tmpList = res.datas.records || []

          this.list = this.searchData.current === 1 ? tmpList : this.list.concat(tmpList)
          this.searchData.total = res.datas.total || 0
          this.loadStatus = res.datas.current < res.datas.pages ? 'loading' : 'nomore'
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (error) {
        this.$hideLoading()
      }
    },
    // 加载更多
    loadMore () {
      if (this.searchData.total / this.searchData.size <= this.searchData.current) {
        return false
      }
      this.searchData.current++
      this.getList()
    },
    // 权益查询
    handleGoInterest () {
      this.$navigateTo('/pages/interests/index')
    },
    // 获取用户信息
    async getUserInfo () {
      try {
        this.$showLoading()
        const res = await this.$Api.mxp_api('/api-member/miniMember/selectMiniMemberCard', 'GET', {
          memberCardId: this.$getStorageSync('memberId'),
        }, true)
        this.$hideLoading()
        if (res.resp_code == 0) {
          this.data = res.datas
          this.$setStorage('userInfo', JSON.stringify(this.data))
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        this.$hideLoading()
      }
    },
    // 获取机构
    async getOrgList () {
      try {
        this.$showLoading()
        const res = await this.$Api.mxp_api('crm-server/org/selectOrgEntitiesForMobile', 'GET', {}, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          let tmpList = res.datas || []
          tmpList.unshift({
            id: '',
            name: "全部"
          })
          tmpList.map(item => {
            item.label = item.name
            item.value = item.id
            item.active = false
          })
          this.orgList = tmpList
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    },
    // 查询当前登陆用户的信息
    async getValidateUserInfo () {
      try {
        this.$showLoading()
        let params = {
          orgId: this.$getStorageSync('orgId'),
          memberId: this.$getStorageSync('memberId'),
          code: this.$getStorageSync('code')
        }
        const res = await this.$Api.mxp_api('crm-server/jinxinMember/selectMemberCardById', 'GET', params, true)
        this.$hideLoading()
        if (res.resp_code === 0) {
          this.userInfo = res.datas || {}
          if (!this.userInfo.verificationUserId) {
            if (process.env.NODE_ENV === 'development') {
              this.getUserInfo()
              this.getOrgList()
              this.handleSearch()
              this.showPage = true
            } else {
              uni.showModal({
                title: '',
                showCancel: false,
                content: '您的账号没有核销权限，请联系管理员',
                success: (res) => {
                  if (res.confirm) {
                    this.wxOptions('closeWindow')
                  }
                }
              });
              this.showPage = false
            }
          } else {
            this.getUserInfo()
            this.getOrgList()
            this.handleSearch()
            this.showPage = true
          }
        } else {
          this.$showToast(res.resp_msg)
        }
      } catch (e) {
        console.error(e)
        this.$hideLoading()
      }
    }
  },
  onPullDownRefresh () {
    setTimeout(function () {
      uni.stopPullDownRefresh();
    }, 1000);
  },
}
</script>

<style lang="scss">
page {
  background-color: #f6fafd;
}

picker-view {
  width: 100%;
  height: 600rpx;
  margin-top: 20rpx;
}
.item {
  line-height: 100rpx;
  text-align: center;
}

.uni-picker-view-content {
  .item {
    font-size: 32rpx;
    color: rgba(0, 0, 0, 0.9);
  }
}
.search-time {
  position: absolute;
  width: 100%;
  left: 0;
  z-index: 999;
  height: 100vh;
  background: #fff;
  &::before {
    content: "";
    width: 100%;
    height: 100%;
    display: block;
    background: rgba(0, 0, 0, 0.6);
  }
  .date-container {
    height: 520rpx;
    padding-bottom: 0 !important;
    position: absolute;
    width: 100%;
    background: #fff;
    top: 0;
    z-index: 9999;
  }
  .date-comp {
    display: flex;
    width: 100%;
    //height: 400rpx;
    flex-direction: column;
    .year {
      width: 33.33%;
      width: 110px;
      font-size: 32rpx;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(0, 0, 0, 0.26);
      view {
        padding: 16rpx 0;
      }
      .active {
        color: rgba(0, 0, 0, 0.9);
      }
    }
    .month {
      width: 33.33%;
      font-size: 32rpx;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(0, 0, 0, 0.26);
      view {
        padding: 16rpx 0;
      }
      .active {
        color: rgba(0, 0, 0, 0.9);
      }
    }
    .date {
      width: 33.33%;
      font-size: 32rpx;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(0, 0, 0, 0.26);
      view {
        padding: 16rpx 0;
      }
      .active {
        color: rgba(0, 0, 0, 0.9);
      }
    }
  }

  .date-opt {
    justify-content: center;
    display: flex;
    height: 96rpx;
    border-top: 1px solid rgba(231, 231, 231, 1);
    align-items: center;
    view {
      display: flex;
      justify-content: center;
      align-items: center;
      height: 72rpx;
      width: 327rpx;
    }
    view:first-child {
      margin-right: 32rpx;
      font-size: 28rpx;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: rgba(0, 0, 0, 0.9);
      background: #ffffff;
      border-radius: 36rpx;
      border: 2rpx solid #c9cbd6;
    }

    view:last-child {
      background: #4474be;
      border-radius: 36rpx;
      font-size: 28rpx;
      font-family: PingFang SC-Regular, PingFang SC;
      font-weight: 400;
      color: #fff;
    }
  }
}

.scan-user {
  height: 100vh;
  overflow: hidden;
  background: #f6fafd;
  .header {
    background: #fff;
    padding: 32rpx 32rpx 0rpx 32rpx;
    .user-card {
      display: flex;
      background: rgba(24, 39, 75, 0.08);
      border-radius: 16rpx;
      flex-direction: column;
      .user-base {
        display: flex;
        padding: 32rpx 32rpx 32rpx 32rpx;
        justify-content: space-between;
        view:first-child {
          display: flex;
          justify-content: center;
          align-items: center;
          .user-avatar {
            width: 96rpx;
            height: 96rpx;
            border-radius: 4rpx;
          }
          .user-name {
            font-size: 32rpx;
            font-family: PingFang SC-Medium, PingFang SC;
            font-weight: 500;
            color: rgba(0, 0, 0, 0.9);
            padding-left: 32rpx;
          }
        }
        view:last-child {
          display: flex;
          flex-direction: column;
          align-items: flex-end;
          .user-total {
            font-size: 24rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.4);
          }
          .user-money {
            font-size: 32rpx;
            font-family: Poppins-Medium, Poppins;
            font-weight: 500;
            color: #4474be;
          }
        }
      }
      .user-other {
        padding-bottom: 32rpx;
        .user-sex,
        .user-birth,
        .user-add {
          padding-left: 32rpx;
          display: flex;
          padding-top: 8rpx;
          view:first-child {
            width: 128rpx;
            font-size: 24rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.4);
            margin-right: 32rpx;
          }
          view:last-child {
            font-size: 24rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.9);
            margin-right: 32rpx;
          }
        }
      }
      .user-qy {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 56rpx;
        background: #4474be;
        border-radius: 0px 0px 16rpx 16rpx;
        font-size: 24rpx;
        font-family: PingFang SC-Medium, PingFang SC;
        font-weight: 500;
        color: #ffffff;
        image {
          width: 32rpx;
          height: 32rpx;
          margin-left: 8rpx;
        }
      }
    }
  }

  .search-header {
    background: #fff;
    padding: 40rpx 32rpx 20rpx 32rpx;
    position: relative;
    .search-title {
      font-size: 32rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.9);
      padding-bottom: 20rpx;
    }
    .search-input {
      padding-bottom: 16rpx;
    }
    .search-tabs {
      height: 88rpx;
      display: flex;
      justify-content: space-between;
      image {
        width: 24rpx;
        height: 24rpx;
        margin-left: 8rpx;
      }
      view {
        display: flex;
        align-items: center;
        font-size: 24rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.6);
      }
    }
    .search-list {
      position: absolute;
      width: 100%;
      left: 0;
      z-index: 999;
      height: 100vh;
      background: #fff;
      &::before {
        content: "";
        width: 100%;
        height: 100%;
        display: block;
        background: rgba(0, 0, 0, 0.6);
      }
      view {
        width: calc(100% - 64rpx);
        padding: 24rpx 0;
        background: #ffffff;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 28rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #323233;
        border-bottom: 1px solid #ebedf0;
        image {
          width: 36rpx;
          height: 36rpx;
        }
      }
      .search-container {
        background: #fff;
        padding-bottom: 0 !important;
        position: absolute;
        top: 0;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        width: 100%;
        height: 720rpx;
      }
    }
  }

  .list {
    .list-item {
      background: #fffefe;
      border-radius: 32rpx;
      padding: 24rpx;
      width: calc(100% - 96rpx);
      margin: 24rpx 48rpx 0 48rpx;

      .item-status {
        justify-content: space-between;
        align-items: center;
        display: flex;
        font-size: 28rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.9);
        view:first-child {
          display: flex;
          align-items: center;
        }
        .status-text {
          font-size: 28rpx;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: #4474be;
        }
        image {
          width: 36rpx;
          height: 36rpx;
          margin-right: 16rpx;
        }
      }
      .item-bottom {
        display: flex;
        justify-content: space-between;
        font-size: 24rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.6);
        span {
          font-size: 28rpx;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: #de0346;
        }
      }
      .item-bottom-opt {
        padding-top: 32rpx;
        padding-bottom: 38rpx;
        display: flex;
        align-items: center;
        justify-content: space-between;
        view {
          font-size: 28rpx;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.9);
        }
        .opt-container {
          display: flex;
          view:last-child {
            margin-left: 8rpx;
            background: #4474be;
            border-radius: 44rpx;
            color: #fff;
          }
        }
        .opt-btn {
          border-radius: 36rpx;
          border: 2rpx solid #c9cbd6;
          padding: 8rpx 32rpx;
          &:last-child {
            margin-left: 8rpx;
          }
        }
      }
      .item-detail {
        width: 100%;
        display: flex;
        padding: 24rpx 0;
        .detail-img {
          width: 128rpx;
          height: 128rpx;
          border-radius: 4rpx;
          // margin-right: 16rpx;
        }
        .detail-info {
          width: calc(100% - 128rpx);
          margin-left: 16rpx;
          view:first-child {
            display: flex;
            justify-content: space-between;
            font-size: 28rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.9);
            padding-bottom: 8rpx;
          }
          view:last-child {
            display: flex;
            justify-content: space-between;
            font-size: 24rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.6);
          }
        }
      }
    }

    .filter-tag {
      display: flex;
      background: #fff;
      padding: 32rpx 16rpx;
      margin-top: 8rpx;
      flex-wrap: wrap;
      view {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        background: #4474be;
        border-radius: 24rpx;
        padding: 4rpx 24rpx;
        font-size: 24rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        margin-right: 16rpx;
        margin-top: 8rpx;
        image {
          width: 24rpx;
          height: 24rpx;
          margin-left: 8rpx;
        }
      }
    }

    .empty-data {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      margin-top: 170rpx;
      image {
        width: 320rpx;
        height: 320rpx;
      }
      view {
        font-size: 24rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.4);
      }
    }
  }
}

.scan-user /deep/ .uni-scroll-view-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.scan-user /deep/ uni-picker-view-column {
  height: 400rpx;
}

.scan-user /deep/ uni-picker-view {
  height: 400rpx;
}

.user-list {
  height: calc(100vh - 590rpx);
}

.refresh-bind {
  display: flex;
  padding: 4rpx 16rpx;
  margin-left: 16rpx;
  image {
    width: 32rpx;
    height: 32rpx;
    margin-right: 8rpx;
  }
  font-size: 24rpx;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.6);
  border-radius: 20rpx;
  border: 2rpx solid #9899a8;
}

.relink-popup {
  .relink-body {
    .title {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 20rpx 0;
      font-size: 36rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      font-weight: 500;
      color: rgba(0, 0, 0, 0.9);
    }
    .search {
      padding: 0 24rpx;
    }

    .search-header {
      padding: 0 24rpx;
      display: flex;
      align-items: center;
      justify-content: center;
      height: 96rpx;
      background: #ffffff;
    }
    .no-data {
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      padding-top: 15%;
      padding-bottom: 15%;
      image {
        width: 320rpx;
        height: 320rpx;
      }
      span {
        width: 450rpx;
        text-align: center;
        margin-top: 16rpx;
        font-size: 28rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.4);
      }
    }
    .list {
      padding: 24rpx;
      height: 800rpx;
    }
    .list-item {
      background: #ffffff;
      border-radius: 16rpx;
      padding: 32rpx;
      margin-bottom: 16rpx;
      border-bottom: 2rpx solid rgba(234, 237, 245, 1);
      .base-info {
        justify-content: space-between;
      }
      view {
        display: flex;
        &:first-child {
          width: 100%;
          align-items: center;
          image {
            width: 96rpx;
            height: 96rpx;
            border-radius: 4rpx;
          }
          span {
            font-size: 32rpx;
            font-family: PingFang SC-Medium, PingFang SC;
            font-weight: 500;
            color: rgba(0, 0, 0, 0.9);
            margin-left: 32rpx;
          }
        }
        .btn {
          padding: 8rpx 32rpx;
          background: #4474be;
          border-radius: 44rpx;
          width: 176rpx;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 28rpx;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: #ffffff;
        }
        .unbtn {
          padding: 8rpx 32rpx;
          background: rgba(0, 0, 0, 0.26);
          border-radius: 44rpx;
          width: 148rpx;
          display: flex;
          justify-content: center;
          align-items: center;
          font-size: 28rpx;
          font-family: PingFang SC-Medium, PingFang SC;
          font-weight: 500;
          color: #ffffff;
        }
      }

      .member-name {
        margin-top: 32rpx;
      }
      .member-mobile {
        margin-top: 8rpx;
      }
      .member-name,
      .member-mobile {
        display: flex;

        span {
          font-size: 28rpx;
          font-family: PingFang SC-Regular, PingFang SC;
          font-weight: 400;
          color: rgba(0, 0, 0, 0.9);
          &:first-child {
            width: 128rpx;
            font-size: 28rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            font-weight: 400;
            color: rgba(0, 0, 0, 0.4);
          }
        }
      }
    }
  }
}
</style>
